import req from '@/utils/request'

// 用户模块
/**
 * @description 用户登录接口
 * @param {object} data 一个包含name和password属性的对象
 * @returns
 */
export const login = (data) => {
  console.log(data)
  const options = {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    data,
    url: '/login'
  }
  return req(options)
}
/**
 * @description 用户注册接口
 * @param {object} data 一个包含name和password属性的对象
 * @returns
 */
export const register = (data) => {
  const options = {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    data,
    url: '/register'
  }
  return req(options)
}

// 首页模块
/**
 *
 * @param {object} params {
  '_csrfToken': 'oBPYvBZT5khod6HdwO4pHQGqrY31DG4YSBab3lzm',
  'gender': 'male',
  'pageNum': 1,
  'catId': -1,//表示小说分类的id
  'yearmonth': 202201
}
 * @returns
 */
export const reqYuepiaoRank = async (params) => {
  return req({
    method: 'GET',
    params,
    url: 'qidian/rank/yuepiaolist'
  })
}
// 获取百度排行榜
export const reqBdRank = async (params) => req.get('/bd', params)
// 获取起点新书推荐榜
export const reqRecommendNewBook = async (params) => req.get('/qidian/recommend/newBooklist', params)
// 获取高销量推荐
export const reqRecommendBestSell = async (params) => req.get('/qidian/recommend/bestSelllist', params)
// 获取小说搜索
export const reqSearchBook = async (searchKey) => req.get('/search/' + searchKey)
// 获取小说详细信息
export const reqBookinfo = async (source) => req.get('/bookinfo', { params: { source } })
// 获取小说详章节列表
export const reqChapters = async (source) => req.get('/chapters', { params: { source } })
// 获取小说详细信息
export const reqContent = async (source) => req.get('/content', { params: { source } })
